package Demo;

public class WrongSolution {
    /*
    * 使用三个线程来模拟多线程的场景
    * 使用3条线程，将一个值，从0累加到100
    * */

    //下面是不使用任何锁机制的错误示例
    static Integer num = 0;

    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    while (num < 1000) {
                        System.out.println("Thead Name:" + Thread.currentThread().getName() +" : "+ ++num);
                    }
                }
            });
            thread.start();
        }
    }
}
